var yeahUnitTest = new Object();
yeahUnitTest.tObj = null;

yeahUnitTest.SingleTest = function (step, enter_url)
{
    this.step = step || 1;
    this.enter_url = enter_url || 'http://www.baidu.com/';
    this.href = this.enter_url;
    this.ref = null;
    this.simulate = new ytrace(null, null, this.href, this.ref);
    
    this.output = function(){
        this.post_url = $("#post_url").attr("value") || 'trace.php';
        this.ref = this.href;
        this.href = random_url();

        var output = this.simulate.output(this.href, this.ref);

        $("#msg").append("<li>" + unescape(output) + "</li>");

        $.ajax({
            type : "POST",
            url : this.post_url,
            data : "trace=" + output,
            success : function(msg){
                $("#return").text(msg);
            }
        });
    }
}

var step = 10;
//var post_url = 'http://yeahmobi.oicp.net/yeahtrace/trace.php';

var href = 'http://www.baidu.com/';
var session = null;


function random_url()
{
    return Math.round(20*Math.random()).toString() + '.html';
}

function single_sim()
{
    if(null == yeahUnitTest.tObj)
    {
        yeahUnitTest.tObj = new yeahUnitTest.SingleTest(2);
    }     
    yeahUnitTest.tObj.output();
}
function single_reset()
{
    $("#msg").append("<li></li>");
    yeahUnitTest.tObj = null;
}

$(document).ready(function(){
    $("#single_simulate").click(single_sim);
    $("#single_reset").click(single_reset);
});

/*
function yeahGet(url, data)
{
    url = url + "?trace=" + data;
    script = $('<script type="text/javascript" />')
            .attr('src', c_url);

    $('head')[0].appendChild(script[0]);
}
*/
